package com.duing.util;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class SpiderUtil {

    private static String url = "https://book.qidian.com/info/1979049";

    public static void main (String[] args) {
        try {
            Document document = Jsoup.connect(url).get();

            Elements elements = document.select("h2.book_name > a");
            System.out.println(elements.size());
            for (Element element : elements) {
//                Elements aElements = element.getElementsByTag("a");
                String linkHref = element.attr("href");
                String linkTitle = element.attr("title");

                String subUrl = "https" + linkHref;

                System.out.println(linkHref);
            }
            System.out.println();

        }catch (Exception e){

        }
    }

}
